package exttable.view;

import exttable.timetable.ETestType;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * User: Admin
 * Date: May 3, 2010
 * Time: 1:05:12 AM
 * To change this template use File | Settings | File Templates.
 */
public class ViewAnalysis extends ViewLocales implements Serializable {
    private final int analysisId;
    private final String analysisName;
    private final ViewVersion version;
    private String analysisVersionKey;
    private final Map<ViewVersion, List<ViewAnalysisParameter>> analysisParameters;
    private List<ViewAnalysisParameter> parameters = new ArrayList<ViewAnalysisParameter>();
    private boolean isEditable;
    private ETestType type;

    public int getAnalysisId() {
        return analysisId;
    }

    public String getAnalysisName() {
        return analysisName;
    }

    public String getAnalysisVersionKey() {
        return analysisVersionKey;
    }

    public void setAnalysisVersionKey(String analysisVersionKey) {
        this.analysisVersionKey = analysisVersionKey;
    }

    public Map<ViewVersion, List<ViewAnalysisParameter>> getAnalysisParameters() {
        return analysisParameters;
    }

    public boolean isEditable() {
        return isEditable;
    }

    public void setEditable(boolean editable) {
        isEditable = editable;
    }

    public List<ViewAnalysisParameter> getParameters() {
        return parameters;
    }

    public void setParameters(List<ViewAnalysisParameter> parameters) {
        this.parameters = parameters;
    }

    public ETestType getType() {
        return type;
    }

    public void setType(ETestType type) {
        this.type = type;
    }

    public static class Build implements IBuilder {
        private int analysisId;
        private String analysisName;
        private String nameRu;
        private String nameKz;
        private String nameEn;
        private Map<ViewVersion, List<ViewAnalysisParameter>> analysisParameters;
        private ViewVersion version;
        private boolean isEditable;


        public Build analysId(int analysId) {
            this.analysisId = analysId;
            return this;
        }

        public Build nameRu(String nameRu) {
            this.nameRu = nameRu;
            return this;
        }

        public Build nameKz(String nameKz) {
            this.nameKz = nameKz;
            return this;
        }

        public Build nameEn(String nameEn) {
            this.nameEn = nameEn;
            return this;
        }

        public Build analysName(String analysName) {
            this.analysisName = analysName;
            return this;
        }

        public Build analysisParameters(Map<ViewVersion, List<ViewAnalysisParameter>> analysisParameters) {
            this.analysisParameters = analysisParameters;
            return this;
        }

        public Build viewVersion(ViewVersion version) {
            this.version = version;
            return this;
        }

        public Build isEditable(boolean isEditable) {
            this.isEditable = isEditable;
            return this;
        }


        @Override
        public ViewAnalysis build() {
            return new ViewAnalysis(this);
        }
    }

    public ViewAnalysis(Build build) {
        analysisId = build.analysisId;
        analysisName = build.analysisName;
        analysisParameters = build.analysisParameters;
        version = build.version;
        setNameRu(build.nameRu);
        setNameEn(build.nameEn);
        setNameKz(build.nameKz);
        isEditable=build.isEditable;
    }

}
